<?php
/*
Plugin Name: ja Nicolas Gbenou
Description: permet l'ajout et la gestion d'ja
Version: 1.0.0
*/
include 'form.php';
include 'class.upload.php';
 class wp_ja
    {
        /**
         * Constructor
         */
        var $adminOptionsName = 'wp_jaAdminOptions';  
        
        function wp_ja()
        {
            
        }
        function display_form(){
          global $wpdb;
          
          wp_enqueue_script('masonry', '/wp-content/plugins/ja2014/jquery.validate.min.js');
          wp_enqueue_style('wp_jschat', '/wp-content/plugins/ja2014/style.css');
                                                                        
          include('template_form.php');          
          include('valide_form.php');       
        }
        
        function display_resultform(){
            include('template_recommand.php'); 
            wp_enqueue_style('wp_jschat', '/wp-content/plugins/ja2014/style.css');
        }
        

}   
if (class_exists('wp_ja')) {
       $ja = new wp_ja();
       add_shortcode( 'ja', array($ja, 'display_ja'), 1);
       add_shortcode( 'formja', array($ja, 'display_form'), 1);
       add_shortcode( 'resultja', array($ja, 'display_resultform'), 1);
}

function ja_AdminMenu() {
          if (function_exists('add_menu_page')) {
          $plugin_page_options = add_menu_page('Nom du Lien', 'ja', 'administrator', basename(__FILE__), 'fonction_admin_ja');
          }
}

function fonction_admin_ja() {
  global $wpdb;
  if (!current_user_can('administrator'))  {
    wp_die( __('You do not have sufficient permissions to access this page.') );
    echo 'die';
  }

  echo '<div class="wrap">';
  echo '<p>Ceci est l\'endroit où placer le formulaire des options.</p>';
  echo '</div>';
  include('admin/admin.php');

}

function save_bdd($nom, $prenom, $adresse, $cp, $ville, $tel, $email, $du, $cg){
    global $wpdb; 
    
    return $wpdb->insert( 
        'wp_ja', 
        array( 
            'nom' => $nom, 
            'prenom' => $prenom, 
            'adresse' => $adresse, 
            'cp' => $cp, 
            'ville' => $ville, 
            'tel' => $tel, 
            'email' => $email, 
            'du' => $du, 
            'cg' => $cg, 
            'timestamp' => date("d-m-Y H:i:s")
        ), 
        array( 
            '%s', 
            '%s', 
            '%s', 
            '%s',
            '%s',
            '%s',
            '%s',
            '%s',
            '%s',
            '%s' 
        ) 
    );

}

add_action( 'admin_menu', 'ja_AdminMenu' );
